package com.hyphenate.easeui.utils.permssion;

import android.annotation.TargetApi;
import android.app.Fragment;
import android.content.Context;
import android.os.Build;
import android.support.annotation.NonNull;

/**
 * Description:
 * Author:洪培林
 * Date:2017-09-27
 */
@TargetApi(Build.VERSION_CODES.M)
public class PermissionFragment extends Fragment {
    private PermissionFragmentDelegate mDelegate = new PermissionFragmentDelegate(this);

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mDelegate.onAttach();
    }

    void request(@NonNull String[] permissions, OnRequestPermissionsResultListener listener) {
        mDelegate.request(permissions, listener);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        mDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mDelegate.onDetach();
    }
}
